function searchPre() {
      // 隐藏控件
      var pageAll= this.document.getElementById("pageAll")
      pageAll.style.display="none"
        // 隐藏控件
    var pageSearch= this.document.getElementById("pageSearch")
    pageSearch.style.display="block"
    // 封装到外面
    var url = 'http://192.168.0.110:8080/CarManage/carBrandSearch'
    function r(datas) {
        function operateFormatter(value, row, index) {//赋予的参数
            return [
                '<button class="btn btn-primary" style="margin-right:10px" onclick="editBrand(' + row.brandid + ')">编辑</button>',
                '<button class="btn btn-primary" onclick="seriesBrand(' + row.brandid + ')">系列</button>',
            ].join('');
        }
         // 设置table列样式
         function  formatFormatter(value, row, index) {
            if (value == 1){
            
            return [
               
                '<img src="../../../images/success.png" onclick="statusChange(' + row.validflag+','+row.brandid + ')">',
            ].join('');
        }else{
            return [
               
                '<img src="../../../images/fail.png" onclick="statusChange(' + row.validflag +','+row.brandid + ')">',
            ].join('');
        }
        }
        var tableColumns = [
            {
                field: 'brandid',
                title: '品牌ID',
                switchable: true
            }, {
                field: 'name',
                title: '名称',
                switchable: true
            }, {
                field: 'prefix',
                title: '拼音首字母',
                switchable: true
            }, {
                field: 'validflag',
                title: '状态',
                formatter: formatFormatter
            }, {
                field: 'operate',
                title: '操作',
                formatter: operateFormatter //自定义方法，添加操作按钮
            }
        ];
        $("#table").bootstrapTable('destroy'); //分页必须写
        $('#table').bootstrapTable('refresh');
        $("#table").bootstrapTable({
            cache: false,
            pagination: true,
            sidePagination: "client",  //分页方式：client客户端分页，server服务端分页（*）
            pageNumber: 1,   //初始化加载第一页，默认第一页
            pageSize: 10,   //每页的记录行数（*）
            //  pageList: [10, 20, 50, 100], //可供选择的每页的行数
            columns: tableColumns,
            data: datas,
            queryParamsType: '',
            //得到查询的参数
            queryParams: function queryParams(params) {
                return params;
            },
            onLoadSuccess: function (data) {  //加载成功时执行
                alert("成功" + data)
            },
            onLoadError: function () {  //加载失败时执行
                alert("失败")
            }
        });
    }
    // 传四个参数
    var currentPage = 1
    var pageSize = 10
      // 判断是否为当前页，或者最后一页，隐藏上一页或者下一页
      if (currentPage == 1 ) {
        $(".page_prevs").css({ display: "none" });
    }else if( currentPage == totalPage){
        $(".page_nexts").hide();
    }
    //获取输入的名称和首字母查询
    var name = document.getElementById("name").value
    var prefix = document.getElementById("prefix").value
    console.log(name+prefix)
    var date = {
        currentPage: currentPage,
        pageSize: pageSize,
        name: name,
        prefix: prefix
    }
    // 对象变为字符串
    var datass=JSON.stringify(date)
    //  判断为空
    $.ajax({
        url: url,//请求后台的url
        method: 'post',//请求方式
        contentType: "application/json",
        data:datass,
        success: function (res) {
            console.log(res.data.total)
            var total = res.data.total
            // 有余数向上取整
            var totalPage = Math.ceil(total / 10)
            r(res.data.list)
            //上一页
            $(".page_prevs").click(function () {
                if (currentPage > 1) {
                    currentPage--;
                    $("#currentPages").text('当前第' + currentPage + '页');
                    console.log(currentPage)
                    var date = {
                        currentPage: currentPage,
                        pageSize: pageSize,
                        name: name,
                        prefix: prefix
                    }
                    var dates = JSON.stringify(date)
                    $.ajax({
                        url: url,//请求后台的url
                        method: 'post',//请求方式
                        contentType: "application/json",
                        data: dates,
                        success: function (res) {
                            console.log(res)
                            console.log(res.data.total + '总数')
                            r(res.data.list)
                        },
                        error: function () {
                            console.log('错误')
                        }
                    })
                    $(".page_prevs").css({ display: "inline-block" });
                }
                if (currentPage == 1) {
                    $(".page_prevs").hide();
                }
                if (currentPage < totalPage) {
                    $(".page_nexts").css({ display: "inline-block" });
                }
            });
            //显示总条数
            $("#totals").text('共' + total + '条记录');
            //显示总页数
            $("#totalPages").text('共' + totalPage + '页');
            //当前页
            $("#currentPages").text('当前第' + currentPage + '页');
            //下一页
            $(".page_nexts").click(function () {
                if (currentPage < totalPage) {
                    currentPage++;
                    console.log(currentPage)
                    $("#currentPages").text('当前第' + currentPage + '页');
                    var date = {
                        currentPage: currentPage,
                        pageSize: pageSize,
                        name: name,
                        prefix: prefix
                    }
                    var dates = JSON.stringify(date)
                    $.ajax({
                        url: url,//请求后台的url
                        method: 'post',//请求方式
                        contentType: "application/json",
                        data: dates,
                        success: function (res) {
                            console.log(res)
                            console.log(res.data.total + '总数')
                            r(res.data.list)
                        },
                        error: function () {
                            console.log('错误')
                        }
                    })
                    $(".page_nexts").css({ display: "inline-block" });

                }
                if (currentPage > 1) {
                    $(".page_prevs").css({ display: "inline-block" });
                }
                if (currentPage == totalPage) {
                    $(".page_nexts").hide();
                }
            });
        },

    })
}